﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace FFmpegVideoClip.Lib.UtilityControlsTools
{
    [ValueConversion(typeof(string[]), typeof(string))]
    public class FragmentDurationConvert : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Length < 2)
                return "Error";
            try
            {
                return Tools.GetTimeSpanToString(Tools.GetStringTimeToTimeSpan(values[1].ToString()!) - Tools.GetStringTimeToTimeSpan(values[0].ToString()!));
            }
            catch (Exception)
            {
                return "Error";
            }
            
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
